package com.ruoyi.zxjd.work.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.zxjd.work.domain.WorkTemplateTable6;
import com.ruoyi.zxjd.work.domain.bo.WorkProgressBO;
import com.ruoyi.zxjd.work.mapper.WorkTemplateTable6Mapper;
import com.ruoyi.zxjd.work.service.ICommonWorkTemplateTableService;
import com.ruoyi.zxjd.work.service.IWorkTemplateTable6Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 收到纪检监察干部问题线索办理情况Service业务层处理
 * 
 * @author lcc
 * @date 2021-03-01
 */
@Service
public class WorkTemplateTable6ServiceImpl implements IWorkTemplateTable6Service 
{
    @Autowired
    private WorkTemplateTable6Mapper workTemplateTable6Mapper;
    @Autowired
    private WorkProgressServiceImpl workProgressService;

    @Autowired
    private ICommonWorkTemplateTableService commonWorkTemplateTableService;
    /**
     * 查询收到纪检监察干部问题线索办理情况
     * 
     * @param id 收到纪检监察干部问题线索办理情况ID
     * @return 收到纪检监察干部问题线索办理情况
     */
    @Override
    public WorkTemplateTable6 selectWorkTemplateTable6ById(Long id)
    {
        return workTemplateTable6Mapper.selectWorkTemplateTable6ById(id);
    }

    /**
     * 查询收到纪检监察干部问题线索办理情况列表
     * 
     * @param workTemplateTable6 收到纪检监察干部问题线索办理情况
     * @return 收到纪检监察干部问题线索办理情况
     */
    @Override
    public List<WorkTemplateTable6> selectWorkTemplateTable6List(WorkTemplateTable6 workTemplateTable6)
    {
        return workTemplateTable6Mapper.selectWorkTemplateTable6List(workTemplateTable6);
    }

    /**
     * 新增收到纪检监察干部问题线索办理情况
     * 
     * @param workProgressBO 收到纪检监察干部问题线索办理情况
     * @return 结果
     */
    @Override
    public int insertWorkTemplateTable6(WorkProgressBO workProgressBO)
    {
        commonWorkTemplateTableService.insertOrUpdate(workProgressBO,"getWorkTemplateTable6", workTemplateTable6Mapper);
        return workProgressService.validate(workProgressBO.getWorkProgress());
    }

    /**
     * 修改收到纪检监察干部问题线索办理情况
     * 
     * @param workTemplateTable6 收到纪检监察干部问题线索办理情况
     * @return 结果
     */
    @Override
    public int updateWorkTemplateTable6(WorkTemplateTable6 workTemplateTable6)
    {
        workTemplateTable6.setUpdateBy(ShiroUtils.getLoginName());
        workTemplateTable6.setUpdateTime(DateUtils.getNowDate());
        return workTemplateTable6Mapper.updateWorkTemplateTable6(workTemplateTable6);
    }

    /**
     * 删除收到纪检监察干部问题线索办理情况对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWorkTemplateTable6ByIds(String ids)
    {
        return workTemplateTable6Mapper.deleteWorkTemplateTable6ByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除收到纪检监察干部问题线索办理情况信息
     * 
     * @param id 收到纪检监察干部问题线索办理情况ID
     * @return 结果
     */
    @Override
    public int deleteWorkTemplateTable6ById(Long id)
    {
        return workTemplateTable6Mapper.deleteWorkTemplateTable6ById(id);
    }

    /**
     * 查询收到纪检监察干部问题线索办理情况
     * 
     * @param progressId 工作进度id
     * @return 收到纪检监察干部问题线索办理情况
     */
    @Override
    public WorkTemplateTable6 selectWorkTemplateTable6ByProgressId(Long progressId)
    {
        return workTemplateTable6Mapper.selectWorkTemplateTable6ByProgressId(progressId);
    }


    /**
     * 查询收到纪检监察干部问题线索办理情况
     * 
     * @param arrangeId 
     * @return 收到纪检监察干部问题线索办理情况
     */
    @Override
	public Map<String,Object> selectWorkTemplateTable6ByArrangeId(Long arrangeId)
    {
        Map<String,Object> resultMap = new HashMap<>();
        Map<String,Object> map = workTemplateTable6Mapper.selectWorkTemplateTable6ByArrangeId(arrangeId);
        Set<String> set = map.keySet();
        Iterator<String> iterator = set.iterator();
        while(iterator.hasNext()){
            String key = String.valueOf(iterator.next());
            String value = String.valueOf(map.get(key));
            value = StringUtils.equals("0", value)?"":value;
            resultMap.put(key, value);
        }
        return resultMap;
    }
}
